package src.model.gameWorld;

import src.event.*;
import src.event.events.*;

/**
 * <b>Overview</b><br>
 * <p>In orderto pass messages form the gameObject subsystem to the gameWorld
 * subsystem, a static communicaiotn line must in place</p>
 * <br><br>
 * <b>Responsibilites</b><br>
 * <p>initiate communication (event passing) between outside subsystems and 
 * the gameWorld subsystem.</p>
 * <br><br>
 * <b>Collaborators</b>
 * <ul>
 * <li>EventHandler<T> - Subcontractor</li>
 * </ul>
 * <br><br>
 * <b>Implementor</b> - Brent<br>
 * <b>Tester</b> - Tim<br>
 * 
 * @author Brent
 *
 */
public class GameWorldEventHandler {

	private static GameWorldEventHandler staticReference;
	
	private EventHandler<AddObject> addObjectEventHandler;
	private EventHandler<RemoveObject> removeObjectEventHandler;
	private EventHandler<UpdateView> updateViewEventHandler;
	private EventHandler<UpdateGameDataObject> updateGameDataObjectEventHandler;
	private EventHandler<ModifyResources> modifyResourcesEventHandler;
	
	public GameWorldEventHandler()
	{
		staticReference = this;
		
		addObjectEventHandler = new EventHandler<AddObject>();
		removeObjectEventHandler = new EventHandler<RemoveObject>();
		updateViewEventHandler = new EventHandler<UpdateView>();
		updateGameDataObjectEventHandler = new EventHandler<UpdateGameDataObject>();
		modifyResourcesEventHandler = new EventHandler<ModifyResources>();
	}
	
	EventHandler<AddObject> getAddObjectEventHandler()
	{
		return addObjectEventHandler;
	}
	
	EventHandler<RemoveObject> getRemoveObjectEventHandler()
	{
		return removeObjectEventHandler;
	}
	
	EventHandler<UpdateView> getUpdateViewEventHandler()
	{
		return updateViewEventHandler;
	}
	
	EventHandler<UpdateGameDataObject> getUpdateGameDataObjectEventHandler()
	{
		return updateGameDataObjectEventHandler;
	}
	
	EventHandler<ModifyResources> getModifyResourcesEventHandler()
	{
		return modifyResourcesEventHandler;
	}
	
	static GameWorldEventHandler getReference()
	{
		return staticReference;
	}
	
	public static void fireEvent(AddObject e)
	{
		staticReference.getAddObjectEventHandler().fireEvent(e);
	}
	
	public static void fireEvent(RemoveObject e)
	{
		staticReference.getRemoveObjectEventHandler().fireEvent(e);
	}
	
	public static void fireEvent(UpdateView e)
	{
		staticReference.getUpdateViewEventHandler().fireEvent(e);
	}
	
	public static void fireEvent(UpdateGameDataObject e)
	{
		staticReference.getUpdateGameDataObjectEventHandler().fireEvent(e);
	}
	
	public static void fireEvent(ModifyResources e)
	{
		staticReference.getModifyResourcesEventHandler().fireEvent(e);
	}
	
	public static boolean fireEventNow(AddObject e)
	{
		return staticReference.getAddObjectEventHandler().fireEventNow(e);
	}
	
	public static boolean fireEventNow(RemoveObject e)
	{
		return staticReference.getRemoveObjectEventHandler().fireEventNow(e);
	}
	
	public static boolean fireEventNow(UpdateView e)
	{
		return staticReference.getUpdateViewEventHandler().fireEventNow(e);
	}
	
	public static boolean fireEventNow(UpdateGameDataObject e)
	{
		return staticReference.getUpdateGameDataObjectEventHandler().fireEventNow(e);
	}
	
	public static boolean fireEventNow(ModifyResources e)
	{
		return staticReference.getModifyResourcesEventHandler().fireEventNow(e);
	}
}
